package com.maserb.monitor.entity.jwQuestion;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import com.fasterxml.jackson.annotation.JsonBackReference;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.List;

//问卷问题表
@Data
@Entity
@Table(name = "jw_question_item")
@ExcelTarget("JwQuestionItemEntity")
public class JwQuestionItemEntity {

    @GenericGenerator(name = "idGenerator", strategy = "uuid")
    @GeneratedValue(generator = "idGenerator")
    @Id
    private String id;
    //标题
    @Column (length = 1000)
    @Excel(name = "问题题目", orderNum = "1", width = 40,needMerge = true)
    @NotNull
    private String name;
    //类型（单选、多选、问答题）(1,"单选"),DuoXuan(2,"多选"),WenDa(3,"问答题");
    @Excel(name = "类型",replace = { "单选_1","多选_2","问答题_3" }, orderNum = "2", width = 20,needMerge = true)
    private String type;
    //排序
    private int orderIndex;
    //分值
    private Double score;
    //描述
    @Column (length = 400)
    private String description;
    //是否删除
    private String isDel;
    //状态
    private String status;
    private String createUser;
    private String createTime;
    private String updateUser;
    private String updateTime;

    @ExcelCollection(name = "选项", orderNum = "3")
    @OneToMany(mappedBy = "parent")
    private List<JwQuestionOptionEntity> options;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id")
    @JsonBackReference
    private JwQuestionEntity parent;

}
